<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 输入月份，显示当月天数（输入2月时需要再次输入年份判断是不是闰年后在显示当月天数） -->


    <script type="text/javascript">
        var month = parseInt(prompt('请输入月份', 4))
        switch (month) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                alert('该月为31天');
                break;
            case 2:
                var year = parseInt(prompt('请输入年份', 2008))
                if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
                    alert('该月为29天')
                    break;
                } else {
                    alert('该月为28天')
                    break;
                }
            default:
                alert('该月为30天');
                break;

        }
    </script>
</body>

</html>